<template>
	<view>
		<view class="mainpadding2" style="padding-bottom: 100rpx;">
			<view class="pdl margin_top" v-for="item in list" :key="item.id">
				<view class="xiaohei main_size">{{item.content}}</view>
				<view class="flexright" @click="delitem(item.id)">
					<u-icon name="trash" color="#777" size="18"></u-icon>
					<view class="xiaohui strongtext">删除</view>
				</view>
			</view>
		</view>
		<view class="mainpadding posibottom">
			<view class="submitbtn" @click="name='';;show=true;">添加常用语</view>
		</view>
		<u-modal :show="show" title="常用语" confirmColor="#c1282e" @confirm="confirm" 
			@cancel="show=false" showCancelButton>
			<view class="slot-content" style="width: 600rpx;">
				<view class="flexbetween margin_top">
					<textarea type="text" class="" placeholder="请输入" style="width: 100%;" v-model="name"></textarea>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show:false,
				name:"",
				group_id:"",
				list:[],
			}
		},
		onLoad(options) {
			this.group_id = options.id
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('/webim/Groups/cyyIndex', 'GET', {
					webim_groups_id: this.group_id,
				}).then(res => {
					this.list = res.data
				})
			},
			delitem(id) {
				httpRequest.request("/webim/Groups/delCyy", 'GET', {
					id
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
					}
				})
			},
			confirm(){
				if(this.name==""){
					httpRequest.toast("请输入内容")
					return false
				}
				httpRequest.request('/webim/Groups/addCyy', 'GET', {
					webim_groups_id: this.group_id,
					content:this.name
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.show = false
						this.init()
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
</style>
